﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Camc.Quality.Migrations
{
    public partial class add_clearsignaturerecord : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ClearSignatureRecord",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    FileId = table.Column<Guid>(nullable: false),
                    ProcessId = table.Column<Guid>(nullable: false),
                    StepId = table.Column<Guid>(nullable: false),
                    TableId = table.Column<Guid>(nullable: false),
                    RowId = table.Column<Guid>(nullable: false),
                    RecordRemark = table.Column<string>(nullable: true),
                    InspectionSignatureName = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ClearSignatureRecord", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "ClearSignatureDataStruce",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    ClearSignatureRecordId = table.Column<Guid>(nullable: false),
                    FieldName = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    Enable = table.Column<bool>(nullable: false),
                    Show = table.Column<bool>(nullable: false),
                    Property = table.Column<int>(nullable: false),
                    ColumnType = table.Column<int>(nullable: false),
                    Index = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ClearSignatureDataStruce", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ClearSignatureDataStruce_ClearSignatureRecord_ClearSignatureRecordId",
                        column: x => x.ClearSignatureRecordId,
                        principalTable: "ClearSignatureRecord",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "ClearSignatureRowData",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    ClearSignatureRecordId = table.Column<Guid>(nullable: false),
                    FieldName = table.Column<string>(nullable: true),
                    DisplayName = table.Column<string>(nullable: true),
                    Enable = table.Column<bool>(nullable: false),
                    Show = table.Column<bool>(nullable: false),
                    Property = table.Column<int>(nullable: false),
                    ColumnType = table.Column<int>(nullable: false),
                    Value = table.Column<string>(nullable: true),
                    NewValue = table.Column<string>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ClearSignatureRowData", x => x.Id);
                    table.ForeignKey(
                        name: "FK_ClearSignatureRowData_ClearSignatureRecord_ClearSignatureRecordId",
                        column: x => x.ClearSignatureRecordId,
                        principalTable: "ClearSignatureRecord",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_ClearSignatureDataStruce_ClearSignatureRecordId",
                table: "ClearSignatureDataStruce",
                column: "ClearSignatureRecordId");

            migrationBuilder.CreateIndex(
                name: "IX_ClearSignatureRowData_ClearSignatureRecordId",
                table: "ClearSignatureRowData",
                column: "ClearSignatureRecordId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "ClearSignatureDataStruce");

            migrationBuilder.DropTable(
                name: "ClearSignatureRowData");

            migrationBuilder.DropTable(
                name: "ClearSignatureRecord");
        }
    }
}
